package com.company.task1;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class AddStudentInfo{

    public static void addFunction(List<ArrayList> studentList) throws AgeException, StudentNoException {

        Scanner sc = new Scanner(System.in);
        int newAge;
        String newStuNo;

        List list = new ArrayList();
        studentList.add((ArrayList) list);

        System.out.println("请输入添加的学生学号：");
        newStuNo = sc.next();

        if(newStuNo.startsWith("A")){

            list.add(newStuNo);

        } else{

            throw new StudentNoException("学号不合理哦！");
        }

        System.out.println("请输入添加的学生姓名：");
        list.add(sc.next());

        System.out.println("请输入添加的学生年龄：");
        newAge = sc.nextInt();
        if(newAge > 0 && newAge < 150){

            list.add(newAge);

        } else{

            throw new AgeException("年龄不合理哦！");
        }
    }
}
